Creation date: 2025/08/04 Modified Date & Time: 2025/08/20 @ 11:20

1 Load Libraries

library(shiny)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0      ✔ purrr   0.3.5 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout

2 Load Data

Note: SiteDetails-TEST-GOE-Monitor.csv has space in front of values for Site, Land Manager, Main Restoration Type, Restoration Intensity this effects sorting and other stuff … NEED TO change first

geo_eccc <- read.csv("TEST-GOE-Monitor.csv", header = TRUE, sep = ",")
Sites_eccc <- read.csv("SiteDetails-TEST-GOE-Monitor.csv", header = TRUE, sep = ",")

3 Data

3.1 Column Names

colnames(geo_eccc)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"
colnames(Sites_eccc)
## [1] "Subregion"             "Site"                  "Land.Manager"         
## [4] "Main.Restoration.Type" "Restoration.Intensity" "Area.ha"              
## [7] "Lat"                   "Lng"

3.2 Data Structure

str(geo_eccc)
## 'data.frame':    24 obs. of  8 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Gulf Islands" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Brackman Island" "Crows Nest" ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.77 0.66 0.75 0.53 0.45 0.65 0.62 0.58 ...
##  $ Cultural_species_richness   : num  2.71 1.3 2.8 1.07 3.6 0.8 0.42 2 3.6 2.33 ...
##  $ Exotic_species              : num  0.17 57.19 11.17 31.51 8.8 ...
##  $ Trampling                   : num  5 4.7 5.4 1.64 12.2 ...
##  $ Herbivory                   : num  1.14 36.5 0 26.71 0.1 ...
##  $ Composite_Index             : num  1.8 0.6 2 1 1.6 0.8 0.2 1.4 1 1 ...
str(Sites_eccc)
## 'data.frame':    24 obs. of  8 variables:
##  $ Subregion            : chr  "Saanich Peninsula" "Saanich Peninsula" "Saanich Peninsula" "Saanich Peninsula" ...
##  $ Site                 : chr  "Gore Park" "Highrock Park" "Mill Hill Park" "Oak Haven Park" ...
##  $ Land.Manager         : chr  "Central Saanich" "City of Esquimalt" "CRD" "CRD" ...
##  $ Main.Restoration.Type: chr  "invasive removal" "invasive removal" "invasive removal" "invasive removal" ...
##  $ Restoration.Intensity: chr  "moderate" "low" "high" "high" ...
##  $ Area.ha              : num  0.74 2.88 16.66 3.16 3.36 ...
##  $ Lat                  : num  48.5 48.4 48.5 48.6 48.5 ...
##  $ Lng                  : num  -123 -123 -123 -123 -123 ...

3.3 Combine Dataframes

length(unique(geo_eccc$Site))
## [1] 24
length(unique(Sites_eccc$Site))
## [1] 24

3.3.1 Arrange Order

# tidyverse
# https://stackoverflow.com/questions/68989228/sort-dataframe-by-column-value-r
Sites_eccc_1 <- Sites_eccc %>% arrange(Site)
geo_eccc_1 <- geo_eccc %>% arrange(Site)

3.3.2 cbind arranged df works

  • merge doesn’t work, leaves columns empty
  • now there are 2 Site columns and 2 Subregion columns with same name
geo_eccc_sites <- cbind(Sites_eccc_1, geo_eccc_1)

3.3.3 remove duplicate columns

names(geo_eccc_sites)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land.Manager"                 "Main.Restoration.Type"       
##  [5] "Restoration.Intensity"        "Area.ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Subregion"                    "Site"                        
## [11] "Proportion_of_native_species" "Cultural_species_richness"   
## [13] "Exotic_species"               "Trampling"                   
## [15] "Herbivory"                    "Composite_Index"
# https://stackoverflow.com/questions/7072159/how-do-you-remove-columns-from-a-data-frame
geo_eccc_sites_1 <- geo_eccc_sites[c(-9,-10)]
names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land.Manager"                 "Main.Restoration.Type"       
##  [5] "Restoration.Intensity"        "Area.ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"

3.3.4 Rename columns with . using dplyr

names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land.Manager"                 "Main.Restoration.Type"       
##  [5] "Restoration.Intensity"        "Area.ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"

3.3.5 Rename columns with . using base R

names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land.Manager"                 "Main.Restoration.Type"       
##  [5] "Restoration.Intensity"        "Area.ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"
# names(my_data)[names(my_data) == "Sepal.Length"] <- "sepal_length"

names(geo_eccc_sites_1)[names(geo_eccc_sites_1) == "Land.Manager"] <- "Land_Manager"
names(geo_eccc_sites_1)[names(geo_eccc_sites_1) == "Main.Restoration.Type"] <- "Main_Restoration_Type"
names(geo_eccc_sites_1)[names(geo_eccc_sites_1) == "Restoration.Intensity"] <- "Restoration_Intensity"
names(geo_eccc_sites_1)[names(geo_eccc_sites_1) == "Area.ha"] <- "Area_ha"

names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land_Manager"                 "Main_Restoration_Type"       
##  [5] "Restoration_Intensity"        "Area_ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"

3.3.6 Create new csv file with both datasets

write.csv(geo_eccc_sites_1, "geo_eccc_all_site_data.csv", row.names = FALSE)

4 Data Manipulation

Percentage_of_native_species <- scales::percent(geo_eccc$Proportion_of_native_species)
Percentage_of_native_species
##  [1] "94%" "55%" "77%" "66%" "75%" "53%" "45%" "65%" "62%" "58%" "45%" "67%"
## [13] "62%" "61%" "32%" "64%" "49%" "41%" "47%" "34%" "34%" "44%" "54%" "37%"

4.0.1 proportion to Percentage_of_native_species

Percentage_ns <- geo_eccc$Proportion_of_native_species * 100
Percentage_ns
##  [1] 94 55 77 66 75 53 45 65 62 58 45 67 62 61 32 64 49 41 47 34 34 44 54 37

5 add column

Click to see results of data

# https://sparkbyexamples.com/r-programming/add-column-to-dataframe-in-r/
# geo_eccc_1 <- cbind(geo_eccc, Percentage_of_native_species)
# geo_eccc_1

geo_eccc_1 <- cbind(geo_eccc, Percentage_ns)
geo_eccc_1
##            Subregion               Site Proportion_of_native_species
## 1       Gulf Islands Anniversary Island                         0.94
## 2       Gulf Islands               AVNR                         0.55
## 3       Gulf Islands    Brackman Island                         0.77
## 4       Gulf Islands         Crows Nest                         0.66
## 5       Gulf Islands       Dock Islet N                         0.75
## 6       Gulf Islands        Eagle Islet                         0.53
## 7       Gulf Islands         Mt Maxwell                         0.45
## 8       Gulf Islands          Owl Islet                         0.65
## 9       Gulf Islands         Reay Islet                         0.62
## 10      Gulf Islands     Retreat Island                         0.58
## 11      Gulf Islands          Rum Islet                         0.45
## 12      Gulf Islands           SISCENEM                         0.67
## 13 Saanich Peninsula     Bear Hill Park                         0.62
## 14 Saanich Peninsula         Camas Hill                         0.61
## 15 Saanich Peninsula Gonzales Hill Park                         0.32
## 16 Saanich Peninsula          Gore Park                         0.64
## 17 Saanich Peninsula      Highrock Park                         0.49
## 18 Saanich Peninsula     Mill Hill Park                         0.41
## 19 Saanich Peninsula     Oak Haven Park                         0.47
## 20 Saanich Peninsula         Scafe Hill                         0.34
## 21 Saanich Peninsula       Seymour Hill                         0.34
## 22 Saanich Peninsula       Stewart Hill                         0.44
## 23 Saanich Peninsula       Trial Island                         0.54
## 24 Saanich Peninsula       Uplands Park                         0.37
##    Cultural_species_richness Exotic_species Trampling Herbivory Composite_Index
## 1                       2.71           0.17      5.00      1.14             1.8
## 2                       1.30          57.19      4.70     36.50             0.6
## 3                       2.80          11.17      5.40      0.00             2.0
## 4                       1.07          31.51      1.64     26.71             1.0
## 5                       3.60           8.80     12.20      0.10             1.6
## 6                       0.80          28.25     16.60      0.00             0.8
## 7                       0.42          64.30     10.00      6.00             0.2
## 8                       2.00          27.72     10.67      0.67             1.4
## 9                       3.60          11.51     11.00      8.00             1.0
## 10                      2.33          33.00     32.33      0.00             1.0
## 11                      1.00          73.21     22.20     70.80             0.0
## 12                      3.40          16.12     12.80      0.50             1.6
## 13                      1.86          24.46      7.57      9.50             1.0
## 14                      2.43          27.19      7.71      4.71             1.4
## 15                      1.00          83.16     10.40      1.20             0.4
## 16                      4.40           7.35      6.20      1.60             1.6
## 17                      1.60          37.10      8.20      1.20             1.0
## 18                      1.56          46.33     14.33     25.67             0.4
## 19                      1.50          34.60      1.88     12.75             1.0
## 20                      1.40          55.35     10.20      1.40             0.4
## 21                      2.20          65.99      9.20      0.20             0.8
## 22                      1.00          79.56      4.80      0.80             0.6
## 23                      3.57          30.73      2.00      0.14             1.6
## 24                      1.45          49.38      2.36      5.82             1.0
##    Percentage_ns
## 1             94
## 2             55
## 3             77
## 4             66
## 5             75
## 6             53
## 7             45
## 8             65
## 9             62
## 10            58
## 11            45
## 12            67
## 13            62
## 14            61
## 15            32
## 16            64
## 17            49
## 18            41
## 19            47
## 20            34
## 21            34
## 22            44
## 23            54
## 24            37

5.1 Column Names 2

colnames(geo_eccc_1)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"             
## [9] "Percentage_ns"

6 Plots

6.1 Site by Percentage Native Species

site_natsp <- ggplot(geo_eccc, 
                    aes(x = Site, y = Percentage_ns)) +
                    geom_point(shape = 18, size = 2) +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Site by Percentage Native Species',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-04")
site_natsp

6.2 Site by Composite_Index

site_natsp <- ggplot(geo_eccc, 
                    aes(x = Site, y = Composite_Index)) +
                    geom_point(shape = 18, size = 2) +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Site by Composite Index',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-04")
site_natsp

6.3 TEST Site by Restoration_Intensity

  • note Reay Islet was showing a separate High, so in original csv I copied High value from another site, aslo Scafe Hill had a different low value …
  • also all high values have a space in front … change all …
  • Having trouble ordering Restoration_Intensity values … see next example
names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land_Manager"                 "Main_Restoration_Type"       
##  [5] "Restoration_Intensity"        "Area_ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"
str(geo_eccc_sites_1)
## 'data.frame':    24 obs. of  14 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Saanich Peninsula" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Bear Hill Park" "Brackman Island" ...
##  $ Land_Manager                : chr  "GINPR " "Saltspring conservancy" "CRD" "GINPR " ...
##  $ Main_Restoration_Type       : chr  "herbivore reduction" "herbivore reduction" "invasive removal" "invasive removal" ...
##  $ Restoration_Intensity       : chr  "high" "high" "low" "high" ...
##  $ Area_ha                     : num  4.39 20.54 3.8 4.41 10.1 ...
##  $ Lat                         : num  48.8 48.8 48.5 48.7 48.4 ...
##  $ Lng                         : num  -123 -123 -123 -123 -124 ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.62 0.77 0.61 0.66 0.75 0.53 0.32 0.64 ...
##  $ Cultural_species_richness   : num  2.71 1.3 1.86 2.8 2.43 1.07 3.6 0.8 1 4.4 ...
##  $ Exotic_species              : num  0.17 57.19 24.46 11.17 27.19 ...
##  $ Trampling                   : num  5 4.7 7.57 5.4 7.71 1.64 12.2 16.6 10.4 6.2 ...
##  $ Herbivory                   : num  1.14 36.5 9.5 0 4.71 ...
##  $ Composite_Index             : num  1.8 0.6 1 2 1.4 1 1.6 0.8 0.4 1.6 ...
site_restInt <- ggplot(geo_eccc_sites_1,
       aes(x = Site, y = Restoration_Intensity, color = Subregion)) +
                    geom_point(shape = 18, size = 2) +
  #geom_bar(stat="identity") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="bottom") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Site by Restoration_Intensity',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-20")
site_restInt

# ggplotly(site_restInt)

6.4 TEST Site by Restoration_Intensity and Exotic_species

names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land_Manager"                 "Main_Restoration_Type"       
##  [5] "Restoration_Intensity"        "Area_ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"
str(geo_eccc_sites_1)
## 'data.frame':    24 obs. of  14 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Saanich Peninsula" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Bear Hill Park" "Brackman Island" ...
##  $ Land_Manager                : chr  "GINPR " "Saltspring conservancy" "CRD" "GINPR " ...
##  $ Main_Restoration_Type       : chr  "herbivore reduction" "herbivore reduction" "invasive removal" "invasive removal" ...
##  $ Restoration_Intensity       : chr  "high" "high" "low" "high" ...
##  $ Area_ha                     : num  4.39 20.54 3.8 4.41 10.1 ...
##  $ Lat                         : num  48.8 48.8 48.5 48.7 48.4 ...
##  $ Lng                         : num  -123 -123 -123 -123 -124 ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.62 0.77 0.61 0.66 0.75 0.53 0.32 0.64 ...
##  $ Cultural_species_richness   : num  2.71 1.3 1.86 2.8 2.43 1.07 3.6 0.8 1 4.4 ...
##  $ Exotic_species              : num  0.17 57.19 24.46 11.17 27.19 ...
##  $ Trampling                   : num  5 4.7 7.57 5.4 7.71 1.64 12.2 16.6 10.4 6.2 ...
##  $ Herbivory                   : num  1.14 36.5 9.5 0 4.71 ...
##  $ Composite_Index             : num  1.8 0.6 1 2 1.4 1 1.6 0.8 0.4 1.6 ...
site_restInt_exotic <- ggplot(geo_eccc_sites_1,
       aes(x = Exotic_species, y = Restoration_Intensity, color = Site)) +
                    geom_point(shape = 18, size = 2) +
  #geom_bar(stat="identity") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend legen won't stick to bottom with ggplotly
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Site by Restoration_Intensity and Exotic Species',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-20")
site_restInt_exotic

 ggplotly(site_restInt_exotic)
# change ggplotly legend to bottom
  # %>% 
 #      plotly::layout(legend=list(x=0, 
 #                                 xanchor='left',
 #                                 yanchor='bottom',
 #                                 orientation='h'))    

6.5 ORDER NOT WORKING Site by Restoration_Intensity

Need to reorder Restoration_Intensity using forcats library from tidyverse https://r-graph-gallery.com/267-reorder-a-variable-in-ggplot2.html

names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land_Manager"                 "Main_Restoration_Type"       
##  [5] "Restoration_Intensity"        "Area_ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"
# Reorder following a precise order
# ??? NOT WORKING

# change character to factor
# str(geo_eccc_sites_1)
# geo_eccc_sites_1$Restoration_Intensity <- as.factor(geo_eccc_sites_1$Restoration_Intensity)
# str(geo_eccc_sites_1)
# # change factor to character
# geo_eccc_sites_1 <- data.frame(lapply(geo_eccc_sites_1, as.character), stringsAsFactors=FALSE)
# str(geo_eccc_sites_1)

# https://stackoverflow.com/questions/18413756/re-ordering-factor-levels-in-data-frame
# mydf$task <- factor(mydf$task, levels = c("up", "down", "left", "right", "front", "back"))
#geo_eccc_sites_1$Restoration_Intensity <- factor(geo_eccc_sites_1$Restoration_Intensity, levels = #c("high", "moderate", "low", "minimal"))
str(geo_eccc_sites_1)
## 'data.frame':    24 obs. of  14 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Saanich Peninsula" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Bear Hill Park" "Brackman Island" ...
##  $ Land_Manager                : chr  "GINPR " "Saltspring conservancy" "CRD" "GINPR " ...
##  $ Main_Restoration_Type       : chr  "herbivore reduction" "herbivore reduction" "invasive removal" "invasive removal" ...
##  $ Restoration_Intensity       : chr  "high" "high" "low" "high" ...
##  $ Area_ha                     : num  4.39 20.54 3.8 4.41 10.1 ...
##  $ Lat                         : num  48.8 48.8 48.5 48.7 48.4 ...
##  $ Lng                         : num  -123 -123 -123 -123 -124 ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.62 0.77 0.61 0.66 0.75 0.53 0.32 0.64 ...
##  $ Cultural_species_richness   : num  2.71 1.3 1.86 2.8 2.43 1.07 3.6 0.8 1 4.4 ...
##  $ Exotic_species              : num  0.17 57.19 24.46 11.17 27.19 ...
##  $ Trampling                   : num  5 4.7 7.57 5.4 7.71 1.64 12.2 16.6 10.4 6.2 ...
##  $ Herbivory                   : num  1.14 36.5 9.5 0 4.71 ...
##  $ Composite_Index             : num  1.8 0.6 1 2 1.4 1 1.6 0.8 0.4 1.6 ...
# https://r-graph-gallery.com/267-reorder-a-variable-in-ggplot2.html
# Reorder following a precise order
# data <- data.frame(
#   name=c("north","south","south-east","north-west","south-west","north-east","west","east"),
#   val=sample(seq(1,10), 8 )
# )
# p4 <- data %>%
#   mutate(name = fct_relevel(name, 
#             "north", "north-east", "east", 
#             "south-east", "south", "south-west", 
#             "west", "north-west")) %>%
#   ggplot( aes(x=name, y=val)) +
#     geom_bar(stat="identity") +
#     xlab("")
# p4

# https://stackoverflow.com/questions/67387151/reorder-variables-in-a-ggplot-graphic
#geo_eccc_sites_1_ordered <- geo_eccc_sites_1 %>%
 # dplyr::arrange(Restoration_Intensity)
# 
str(geo_eccc_sites_1)
## 'data.frame':    24 obs. of  14 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Saanich Peninsula" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Bear Hill Park" "Brackman Island" ...
##  $ Land_Manager                : chr  "GINPR " "Saltspring conservancy" "CRD" "GINPR " ...
##  $ Main_Restoration_Type       : chr  "herbivore reduction" "herbivore reduction" "invasive removal" "invasive removal" ...
##  $ Restoration_Intensity       : chr  "high" "high" "low" "high" ...
##  $ Area_ha                     : num  4.39 20.54 3.8 4.41 10.1 ...
##  $ Lat                         : num  48.8 48.8 48.5 48.7 48.4 ...
##  $ Lng                         : num  -123 -123 -123 -123 -124 ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.62 0.77 0.61 0.66 0.75 0.53 0.32 0.64 ...
##  $ Cultural_species_richness   : num  2.71 1.3 1.86 2.8 2.43 1.07 3.6 0.8 1 4.4 ...
##  $ Exotic_species              : num  0.17 57.19 24.46 11.17 27.19 ...
##  $ Trampling                   : num  5 4.7 7.57 5.4 7.71 1.64 12.2 16.6 10.4 6.2 ...
##  $ Herbivory                   : num  1.14 36.5 9.5 0 4.71 ...
##  $ Composite_Index             : num  1.8 0.6 1 2 1.4 1 1.6 0.8 0.4 1.6 ...
# this works ...
desired_levels <- c("high", "moderate", "low", "minimal")
geo_eccc_sites_1$Restoration_Intensity <- factor(geo_eccc_sites_1$Restoration_Intensity, levels = desired_levels)
print(levels(geo_eccc_sites_1$Restoration_Intensity)) # New order of levels
## [1] "high"     "moderate" "low"      "minimal"
site_restInt <- ggplot(geo_eccc_sites_1,
       aes(x = Site, y = Restoration_Intensity, color = Subregion)) +
                    geom_point(shape = 18, size = 2) +
  #geom_bar(stat="identity") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="bottom") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Site by Restoration_Intensity',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-20")
site_restInt

#ggplotly(site_restInt)

6.6 Violin Subregion by Exotic_species

subregion_exsp <- ggplot(geo_eccc, 
                    aes(x = Subregion, y = Exotic_species)) +
                    geom_violin(fill = "seagreen2") +
                    geom_boxplot(width = 0.1, fill = "sandybrown") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Subregion by Exotic_species',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-04")
subregion_exsp

# plotly won't work here

6.7 TEST NOTWorking Violin Subregion by Restoration_Intensity

names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land_Manager"                 "Main_Restoration_Type"       
##  [5] "Restoration_Intensity"        "Area_ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"
str(geo_eccc_sites_1)
## 'data.frame':    24 obs. of  14 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Saanich Peninsula" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Bear Hill Park" "Brackman Island" ...
##  $ Land_Manager                : chr  "GINPR " "Saltspring conservancy" "CRD" "GINPR " ...
##  $ Main_Restoration_Type       : chr  "herbivore reduction" "herbivore reduction" "invasive removal" "invasive removal" ...
##  $ Restoration_Intensity       : Factor w/ 4 levels "high","moderate",..: 1 1 3 1 1 1 1 1 3 2 ...
##  $ Area_ha                     : num  4.39 20.54 3.8 4.41 10.1 ...
##  $ Lat                         : num  48.8 48.8 48.5 48.7 48.4 ...
##  $ Lng                         : num  -123 -123 -123 -123 -124 ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.62 0.77 0.61 0.66 0.75 0.53 0.32 0.64 ...
##  $ Cultural_species_richness   : num  2.71 1.3 1.86 2.8 2.43 1.07 3.6 0.8 1 4.4 ...
##  $ Exotic_species              : num  0.17 57.19 24.46 11.17 27.19 ...
##  $ Trampling                   : num  5 4.7 7.57 5.4 7.71 1.64 12.2 16.6 10.4 6.2 ...
##  $ Herbivory                   : num  1.14 36.5 9.5 0 4.71 ...
##  $ Composite_Index             : num  1.8 0.6 1 2 1.4 1 1.6 0.8 0.4 1.6 ...
subregion_restInt <- ggplot(geo_eccc_sites_1, 
                    aes(y = Restoration_Intensity)) +
#                    geom_violin(fill = "seagreen2") +
                    geom_bar(width = 0.1, fill = "sandybrown") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Subregion by Restoration_Intensity',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-20")
subregion_restInt

ggplotly()
# plotly won't work here

6.8 Subregion by Proportion_of_native_species

subregion_natsp <- ggplot(geo_eccc_1, 
                    aes(x = Subregion, y = Percentage_ns)) +
                    geom_violin(fill = "seagreen2") +
                    geom_boxplot(width = 0.1, fill = "sandybrown") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Subregion by Proportion_of_native_species',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-04")
subregion_natsp

7 Plots by Separate Sites

  • use pivot_longer() for single row with multiple columns convert to long

7.1 pivot longer one row to long df

colnames(geo_eccc_1)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"             
## [9] "Percentage_ns"
Anniversary_Island <- geo_eccc_1[1, ]
Anniversary_Island
##      Subregion               Site Proportion_of_native_species
## 1 Gulf Islands Anniversary Island                         0.94
##   Cultural_species_richness Exotic_species Trampling Herbivory Composite_Index
## 1                      2.71           0.17         5      1.14             1.8
##   Percentage_ns
## 1            94
Uplands <- geo_eccc_1[24, ]
Uplands
##            Subregion         Site Proportion_of_native_species
## 24 Saanich Peninsula Uplands Park                         0.37
##    Cultural_species_richness Exotic_species Trampling Herbivory Composite_Index
## 24                      1.45          49.38      2.36      5.82               1
##    Percentage_ns
## 24            37
Gonzales <- geo_eccc_1[15, ]
Gonzales
##            Subregion               Site Proportion_of_native_species
## 15 Saanich Peninsula Gonzales Hill Park                         0.32
##    Cultural_species_richness Exotic_species Trampling Herbivory Composite_Index
## 15                         1          83.16      10.4       1.2             0.4
##    Percentage_ns
## 15            32
Gonzales <- Gonzales[, -c(1,2,3)]
Gonzales
##    Cultural_species_richness Exotic_species Trampling Herbivory Composite_Index
## 15                         1          83.16      10.4       1.2             0.4
##    Percentage_ns
## 15            32
Gonzales_long <- Gonzales %>% pivot_longer(everything(), names_to = "variable", values_to = "value")
Gonzales_long
## # A tibble: 6 × 2
##   variable                  value
##   <chr>                     <dbl>
## 1 Cultural_species_richness   1  
## 2 Exotic_species             83.2
## 3 Trampling                  10.4
## 4 Herbivory                   1.2
## 5 Composite_Index             0.4
## 6 Percentage_ns              32
# delete first 2 columns as they can't be characters also Percentage
Uplands <- Uplands[, -c(1,2,3)]
Uplands
##    Cultural_species_richness Exotic_species Trampling Herbivory Composite_Index
## 24                      1.45          49.38      2.36      5.82               1
##    Percentage_ns
## 24            37
Uplands_long <- Uplands %>% pivot_longer(everything(), names_to = "variable", values_to = "value")
Uplands_long
## # A tibble: 6 × 2
##   variable                  value
##   <chr>                     <dbl>
## 1 Cultural_species_richness  1.45
## 2 Exotic_species            49.4 
## 3 Trampling                  2.36
## 4 Herbivory                  5.82
## 5 Composite_Index            1   
## 6 Percentage_ns             37

7.2 Plot Long Uplands

Uplands_long_plot  <-  ggplot(Uplands_long, 
                    aes(x = variable, y = value)) +
  # https://www.sthda.com/english/wiki/ggplot2-axis-scales-and-transformations
                    ylim(0, 100) +
                    geom_point() +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Uplands Variables',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-04")
Uplands_long_plot

7.3 Compare Uplands

Uplands_long_plot  <-  ggplot(Uplands_long, 
                    aes(x = variable, y = value)) +
  # https://www.sthda.com/english/wiki/ggplot2-axis-scales-and-transformations
                    ylim(0, 100) +
                    geom_point() +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Uplands Variables',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-04")
Uplands_long_plot

7.4 Plot Long Gonzales

Gonzales_long_plot  <-  ggplot(Gonzales_long, 
                    aes(x = variable, y = value)) +
  # https://www.sthda.com/english/wiki/ggplot2-axis-scales-and-transformations
                    ylim(0, 100) +
                    geom_point() +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Gonzales Variables',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-04")
Gonzales_long_plot

7.5 Compare Uplands

Uplands_long_plot_compare  <-  ggplot(Uplands_long, 
                    aes(x = variable, y = value)) +
  # https://www.sthda.com/english/wiki/ggplot2-axis-scales-and-transformations
                    ylim(0, 100) +
                    geom_point() +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Ploting Uplands Variables',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-04")
Uplands_long_plot

7.6 Compare Bar Variables Uplands

compare_bar_uplands  <-  ggplot(Uplands_long, 
                    aes(x = variable, y = value)) +
  
# Exotic_species
  # https://www.sthda.com/english/wiki/ggplot2-axis-scales-and-transformations
                    ylim(0, 100) +
                    geom_bar(stat = "identity", fill = "seagreen") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Comparinging Uplands Variables',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-08")
compare_bar_uplands

7.7 Compare Bar Variables multiple sites

names(geo_eccc_1)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"             
## [9] "Percentage_ns"
compare_bar_multiple_sites  <-  ggplot(geo_eccc_1,
                    aes(x = Site, y = Percentage_ns, fill = Subregion, color = Subregion)) +
  
# Exotic_species
  # https://www.sthda.com/english/wiki/ggplot2-axis-scales-and-transformations
                    ylim(0, 100) +
                    geom_bar(stat = "identity") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Comparinging Uplands Variables',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-08")
compare_bar_multiple_sites

7.8 Arrange Compare Bar Variables multiple sites

# https://r-graph-gallery.com/267-reorder-a-variable-in-ggplot2.html
names(geo_eccc_1)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"             
## [9] "Percentage_ns"
# arrange values
#str(arr)
# geo_eccc_1 %>% arrange(Percentage_ns) -> arr
geo_eccc_1 %>% arrange(desc(Percentage_ns)) %>%
  # updates Site with new arrangement
   mutate(Site = factor(Site, levels = Site)) %>% 
    ggplot(
      aes(x = Site, y = Percentage_ns, fill = Subregion, color = Subregion)) +
  # https://www.sthda.com/english/wiki/ggplot2-axis-scales-and-transformations
                    ylim(0, 100) +
                    geom_bar(stat = "identity") +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="bottom") + 
                    theme(axis.text.x = element_text(angle = 35, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Comparinging Sites',
                      subtitle='ECCC GOE Site Monitoring',
                      caption = "Chart by Wendy Anthony \n 2025-08-19")

7.9 TEST Stacking Bar Variables multiple sites

# https://r-graph-gallery.com/267-reorder-a-variable-in-ggplot2.html
# View(mpg)
# g <- ggplot(geo_eccc_1, aes(Subregion))  
# p <-  g + geom_bar(aes(fill = Site))
# ggplotly(p)
# 
# #https://stackoverflow.com/questions/6693257/making-a-stacked-bar-plot-for-multiple-variables-ggplot2-in-r
# dfr <- data.frame(
#   V1 = c(0.1, 0.2, 0.3),
#   V2 = c(0.2, 0.3, 0.2),
#   V3 = c(0.3, 0.6, 0.5),
#   V4 = c(0.5, 0.1, 0.7),
#   row.names = LETTERS[1:3]
# )
# 
# geo_eccc_2 <- subset(geo_eccc_1, , -c(Subregion))
# 
# geo_eccc_2 %>% rownames_to_column("ID") %>% pivot_longer(!ID) %>%
#   ggplot() +
#   geom_col(aes(x = ID, y = value, fill = name), position = 'fill')
# # Error in `pivot_longer_spec()`:
# #! Can't combine `Site` <character> and `Proportion_of_native_species` <double>.
# 
# names(geo_eccc_1)
#     ggplot(geo_eccc_1,
#       aes(x = Site, y = Percentage_ns, fill = Subregion, color = Subregion)) +
#   # https://www.sthda.com/english/wiki/ggplot2-axis-scales-and-transformations
#                     ylim(0, 100) +
#                     geom_bar(stat = "identity") +
#                     theme_minimal() + #get rid of grey background and tick marks 
#                     theme(legend.position="bottom") + 
#                     theme(axis.text.x = element_text(angle = 35, vjust = 1, hjust=1, size = 7)) +
#                     labs(title='Comparinging Sites',
#                       subtitle='ECCC GOE Site Monitoring',
#                       caption = "Chart by Wendy Anthony \n 2025-08-19")

7.10 NOTWORKING Compare Column Variables Uplands

colnames(geo_eccc_1)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"             
## [9] "Percentage_ns"
geo_eccc_1_filter <- filter(geo_eccc_1, Site %in% c("Uplands Park", "Trial Island")) 

geo_eccc_2_filter <- filter(geo_eccc_1, Site %in% c("Gulf Islands", "Saanich Peninsula")) 


compare_col_uplands <- ggplot(geo_eccc_1_filter, 
  aes(Site, fill = Exotic_species)) + 
  geom_bar(position = "dodge", alpha = 0.5) +
                    theme_minimal() + #get rid of grey background and tick marks 
                    theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
                    labs(title='Comparinging Uplands Variables',
                      subtitle='ECCC',
                      caption = "Chart by Wendy Anthony \n 2025-08-08")
compare_col_uplands


8 TEST NOT WORKING Facet wraps

8.1 facet_wrap(~Subregion)

names(geo_eccc_1)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"             
## [9] "Percentage_ns"
ggplot(geo_eccc_1, 
       aes(x = Site, y = Exotic_species)) +
  geom_col() +
  facet_wrap(~Subregion) +
  theme(legend.position="none") + #remove legend 
   theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
   labs(title='Comparinging Uplands Variables',
      subtitle='ECCC',
      caption = "Chart by Wendy Anthony \n 2025-08-19")

8.2 SAME AS PREVIOUS NOT WORKINGfacet_wrap

names(geo_eccc_1)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"             
## [9] "Percentage_ns"
ggplot(geo_eccc_1, 
       aes(x = Site, y = Exotic_species)) +
  geom_col() +
  facet_wrap(~Subregion) +
  theme(legend.position="none") + #remove legend 
   theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
   labs(title='Comparinging Uplands Variables',
      subtitle='ECCC',
      caption = "Chart by Wendy Anthony \n 2025-08-19")


9 Test GGplot Function

9.1 Violin Chart Function

geo_eccc <- read.csv("TEST-GOE-Monitor.csv", header = TRUE, sep = ",", stringsAsFactors=FALSE)
str(geo_eccc)
## 'data.frame':    24 obs. of  8 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Gulf Islands" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Brackman Island" "Crows Nest" ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.77 0.66 0.75 0.53 0.45 0.65 0.62 0.58 ...
##  $ Cultural_species_richness   : num  2.71 1.3 2.8 1.07 3.6 0.8 0.42 2 3.6 2.33 ...
##  $ Exotic_species              : num  0.17 57.19 11.17 31.51 8.8 ...
##  $ Trampling                   : num  5 4.7 5.4 1.64 12.2 ...
##  $ Herbivory                   : num  1.14 36.5 0 26.71 0.1 ...
##  $ Composite_Index             : num  1.8 0.6 2 1 1.6 0.8 0.2 1.4 1 1 ...
names(geo_eccc)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"
subregion_var_violin <- function(file, title, subtitle, colx, coly, xlab, ylab, caption){
  
    ggplot2::ggplot(file,
        ggplot2::aes(x = colx, y = coly)) +
    ggplot2::geom_violin(fill = "seagreen2") +
    ggplot2::geom_boxplot(width = 0.1, fill = "sandybrown") +
    ggplot2::theme_minimal() + #get rid of grey background and tick marks
    ggplot2::theme(legend.position="none") + #remove legend
    ggplot2::theme(
      axis.text.x = ggplot2::element_text(vjust = 1, hjust = .5, size = 8),
      axis.text.y = ggplot2::element_text(size = 5),
      plot.title = ggplot2::element_text(hjust = 0.5, size = 12),
      plot.subtitle = ggplot2::element_text(hjust = 0.5, size = 12)) +
    #theme(axis.text.x = element_text(angle = 25, vjust = 1, hjust=1, size = 7)) +
    ggplot2::labs(title=title,
         subtitle=subtitle,
         caption = caption,
         x = xlab, y = ylab)
  #subregion_exsp
  
}

subregion_var_violin(geo_eccc, 'Plotting Subregion by Exotic_species', 'ECCC Data Paper', geo_eccc$Subregion, geo_eccc$Exotic_species, "Subregion", "Exotic_species", "Chart by Wendy Anthony \n 2025-09-04")

subregion_var_violin(geo_eccc,'Plotting Subregion by Cultural_species_richness', 'ECCC Data Paper', geo_eccc$Subregion, geo_eccc$Cultural_species_richness, "Subregion", "Cultural_species_richness", "Chart by Wendy Anthony \n 2025-08-16")

9.2 Point Chart Function

9.2.1 ggplot point chart

geo_eccc <- read.csv("TEST-GOE-Monitor.csv", header = TRUE, sep = ",", stringsAsFactors=FALSE)

str(geo_eccc)
## 'data.frame':    24 obs. of  8 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Gulf Islands" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Brackman Island" "Crows Nest" ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.77 0.66 0.75 0.53 0.45 0.65 0.62 0.58 ...
##  $ Cultural_species_richness   : num  2.71 1.3 2.8 1.07 3.6 0.8 0.42 2 3.6 2.33 ...
##  $ Exotic_species              : num  0.17 57.19 11.17 31.51 8.8 ...
##  $ Trampling                   : num  5 4.7 5.4 1.64 12.2 ...
##  $ Herbivory                   : num  1.14 36.5 0 26.71 0.1 ...
##  $ Composite_Index             : num  1.8 0.6 2 1 1.6 0.8 0.2 1.4 1 1 ...
names(geo_eccc)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"
subregion_var_point <- function(file, title, subtitle, colx, coly, xlab, ylab, caption){

ggplot(file, 
                    aes(x = colx, y = coly, colour = Subregion)) +
                    geom_point(shape = 18, size = 2) +
                    theme_minimal() + #get rid of grey background and tick marks
                    theme(legend.position="bottom") +
                    # theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle =35, vjust = 1, hjust=1, size = 7)) +
                    labs(title=title,
                      subtitle=subtitle,
                      caption = caption,
                      x = xlab, y = ylab)
}

subregion_var_point(geo_eccc,'Plotting Site by Percentage Native Species', 'Malloff & Shackelford. (2024). \nFeeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. \nRestoration Futures Lab at the University of Victoria.
', geo_eccc$Site, geo_eccc$Proportion_of_native_species, "Site", "Proportion of native species", "Chart by Wendy Anthony \n 2025-09-16 \n ECCC Data: (Malloff & Shackelford, 2024)")

subregion_var_point(geo_eccc,'Plotting Site by Exotic Species', 'Malloff & Shackelford. (2024). \nFeeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. \nRestoration Futures Lab at the University of Victoria.
', geo_eccc$Site, geo_eccc$Exotic_species, "Site", "Exotic Species", "Chart by Wendy Anthony \n 2025-09-16 \n ECCC Data: (Malloff & Shackelford, 2024)")

9.2.2 plotly ggplot point chart

geo_eccc <- read.csv("TEST-GOE-Monitor.csv", header = TRUE, sep = ",", stringsAsFactors=FALSE)

str(geo_eccc)
## 'data.frame':    24 obs. of  8 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Gulf Islands" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Brackman Island" "Crows Nest" ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.77 0.66 0.75 0.53 0.45 0.65 0.62 0.58 ...
##  $ Cultural_species_richness   : num  2.71 1.3 2.8 1.07 3.6 0.8 0.42 2 3.6 2.33 ...
##  $ Exotic_species              : num  0.17 57.19 11.17 31.51 8.8 ...
##  $ Trampling                   : num  5 4.7 5.4 1.64 12.2 ...
##  $ Herbivory                   : num  1.14 36.5 0 26.71 0.1 ...
##  $ Composite_Index             : num  1.8 0.6 2 1 1.6 0.8 0.2 1.4 1 1 ...
names(geo_eccc)
## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"
subregion_var_point <- function(file, title, subtitle, colx, coly, xlab, ylab, caption){

ggplot(file, 
                    aes(x = colx, y = coly, colour = Subregion)) +
                    geom_point(shape = 18, size = 2) +
                    theme_minimal() + #get rid of grey background and tick marks
                    theme(legend.position="bottom") +
                    # theme(legend.position="none") + #remove legend 
                    theme(axis.text.x = element_text(angle =35, vjust = 1, hjust=1, size = 7)) +
                    labs(title=title,
                      subtitle=subtitle,
                      caption = caption,
                      x = xlab, y = ylab)
}

p2 <- subregion_var_point(geo_eccc,'Plotting Site by Percentage Native Species', 'Malloff & Shackelford. (2024). \nFeeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. \nRestoration Futures Lab at the University of Victoria.
', geo_eccc$Site, geo_eccc$Proportion_of_native_species, "Site", "Proportion of native species", "Chart by Wendy Anthony \n 2025-09-16 \n ECCC Data: (Malloff & Shackelford, 2024)")

subregion_var_point(geo_eccc,'Plotting Site by Exotic Species', 'Malloff & Shackelford. (2024). \nFeeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. \nRestoration Futures Lab at the University of Victoria.
', geo_eccc$Site, geo_eccc$Exotic_species, "Site", "Exotic Species", "Chart by Wendy Anthony \n 2025-09-16 \n ECCC Data: (Malloff & Shackelford, 2024)")

ggplotly(p2)

10 Leaflet Map

10.1 Custom Icons

Sites_eccc <- read.csv("SiteDetails-TEST-GOE-Monitor.csv", header = TRUE, sep = ",")

names(Sites_eccc)
## [1] "Subregion"             "Site"                  "Land.Manager"         
## [4] "Main.Restoration.Type" "Restoration.Intensity" "Area.ha"              
## [7] "Lat"                   "Lng"
library(dplyr)
library(leaflet)
library(htmlwidgets) # for responsive web map

# custom icon
# https://leafletjs.com/examples/custom-icons/
greenLeafIcon <- makeIcon(
  iconUrl = "https://leafletjs.com/examples/custom-icons/leaf-green.png",
  iconWidth = 38, iconHeight = 95,
  iconAnchorX = 22, iconAnchorY = 94,
  shadowUrl = "https://leafletjs.com/examples/custom-icons/leaf-shadow.png",
  shadowWidth = 50, shadowHeight = 64,
  shadowAnchorX = 4, shadowAnchorY = 62
)
# change LeafIcon size 1/2
greenLeafIconSm <- makeIcon(
  iconUrl = "https://leafletjs.com/examples/custom-icons/leaf-green.png",
  iconWidth = 19, iconHeight = 47,
  iconAnchorX = 11, iconAnchorY = 47,
  shadowUrl = "https://leafletjs.com/examples/custom-icons/leaf-shadow.png",
  shadowWidth = 25, shadowHeight = 32,
  shadowAnchorX = 2, shadowAnchorY = 31
)

# Title control
title <- tags$div(HTML('<b>ECC Site Maps</b><br>Malloff & Shackelford. (2024). Feeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. Restoration Futures Lab at the University of Victoria'))
  

ECCC_map <- leaflet(Sites_eccc) %>%
  addProviderTiles("Esri.WorldImagery") %>%
  addMarkers(
             ~ Lng, ~ Lat, icon = greenLeafIconSm,
             popup = paste0("<b>Subregion:</b> ", Sites_eccc$Subregion, "<br>", "<b>Site:</b> ", Sites_eccc$Site, "<br>", "<b>Latitude:</b> ", Sites_eccc$Lat, "<br>", "<b>Longitude:</b> ", Sites_eccc$Lng,  "<br><br>", "<b>Land Manager:</b> ", Sites_eccc$Land.Manager, "<br>", "<b>Main Restoration:</b> ", Sites_eccc$Main.Restoration.Type, "<br>", "<b>Restoration Intensity:</b> ", Sites_eccc$Restoration.Intensity, "<br>", "<b> Area:</b> ", Sites_eccc$Area.ha, " ha")) %>%
  setView(-123.44799, 48.64919, 9) %>%
  addMiniMap(width = 150, height = 150, zoomLevelOffset = -4) %>%
  addControl(title, position = "topright")

# Display map
ECCC_map
# Save map
saveWidget(ECCC_map, "ECCC_map.html")

10.2 Circle Markers

# NOT WORKING - Sites not same
#geo_eccc_sites <- cbind(geo_eccc, Sites_eccc)
# try to add , "<br>",  "<b>Composite Index:</b> ", geo_eccc_sites$Composite_Index
# names(geo_eccc_sites)
names(Sites_eccc)
## [1] "Subregion"             "Site"                  "Land.Manager"         
## [4] "Main.Restoration.Type" "Restoration.Intensity" "Area.ha"              
## [7] "Lat"                   "Lng"
library(dplyr)
library(leaflet)
library(htmlwidgets) # for responsive web map


# Title control
title <- tags$div(HTML('<b>ECC Site Maps</b><br>Malloff & Shackelford. (2024). Feeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. Restoration Futures Lab at the University of Victoria'))
 
# https://rstudio.github.io/leaflet/articles/markers.html 
# Create a palette that maps factor levels to colors
pal <- colorFactor(c("green", "orange"), domain = c("Saanich Peninsula", "Gulf Islands"))

ECCC_map <- leaflet(Sites_eccc) %>%
  addProviderTiles("Esri.WorldImagery") %>%
  addCircleMarkers(
             ~ Lng, ~ Lat, radius = ~ifelse(Subregion == "Saanich Peninsula", 4, 5),
    color = ~pal(Subregion),
    stroke = FALSE, fillOpacity = 0.5,
             popup = paste0("<b>Site:</b> ", Sites_eccc$Site, "<br>", "<b>Subregion:</b> ", Sites_eccc$Subregion, "<br>", "<b>Latitude:</b> ", Sites_eccc$Lat, "<br>", "<b>Longitude:</b> ", Sites_eccc$Lng,  "<br><br>", "<b>Land Manager:</b> ", Sites_eccc$Land.Manager, "<br>", "<b>Main Restoration:</b> ", Sites_eccc$Main.Restoration.Type, "<br>", "<b>Restoration Intensity:</b> ", Sites_eccc$Restoration.Intensity, "<br>", "<b> Area:</b> ", Sites_eccc$Area.ha, " ha")) %>%
  setView(-123.44799, 48.64919, 9) %>%
  addMiniMap(width = 150, height = 150, zoomLevelOffset = -4) %>%
  addControl(title, position = "topright")

# Display map
ECCC_map
# Save map
saveWidget(ECCC_map, "ECCC_map.html")

10.3 Circle Markers Sized to Area

# NOT WORKING - Sites not same
#geo_eccc_sites <- cbind(geo_eccc, Sites_eccc)
# try to add , "<br>",  "<b>Composite Index:</b> ", geo_eccc_sites$Composite_Index
# names(geo_eccc_sites)
names(Sites_eccc)
## [1] "Subregion"             "Site"                  "Land.Manager"         
## [4] "Main.Restoration.Type" "Restoration.Intensity" "Area.ha"              
## [7] "Lat"                   "Lng"
library(dplyr)
library(leaflet)
library(htmlwidgets) # for responsive web map


# Title control
# Malloff & Shackelford. (2024). Feeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. Restoration Futures Lab at the University of Victoria
title <- tags$div(HTML('<p style="font-size:12px;font-weight:bold">ECC Sites Map</p>'))
 
# https://rstudio.github.io/leaflet/articles/markers.html 
# Create a palette that maps factor levels to colors
pal <- colorFactor(c("green", "orange"), domain = c("Saanich Peninsula", "Gulf Islands"))

ECCC_map <- leaflet(Sites_eccc) %>%
  addProviderTiles("Esri.WorldImagery") %>%
  addCircleMarkers(
             ~ Lng, ~ Lat, 
# https://stackoverflow.com/questions/40137212/variable-marker-size-feature-in-leaflet-r
              radius = ~geo_eccc$Composite_Index * 3,    
              # radius = ~Sites_eccc$Area.ha,
                  # radius = ~sqrt(Sites_eccc$Area.ha),
 # size smaller is Saanich, else larger if Gulf            
#             radius = ~ifelse(Subregion == "Saanich Peninsula", 4, 5),
    color = ~pal(Subregion),
    stroke = FALSE, fillOpacity = 0.5,
             popup = paste0("<b>Site:</b> ", Sites_eccc$Site, "<br>", "<b>Subregion:</b> ", Sites_eccc$Subregion, "<br>", "<b>Latitude:</b> ", Sites_eccc$Lat, "<br>", "<b>Longitude:</b> ", Sites_eccc$Lng,  "<br><br>", "<b>Land Manager:</b> ", Sites_eccc$Land.Manager, "<br>", "<b>Main Restoration:</b> ", Sites_eccc$Main.Restoration.Type, "<br>", "<b>Restoration Intensity:</b> ", Sites_eccc$Restoration.Intensity, "<br>", "<b> Area:</b> ", Sites_eccc$Area.ha, " ha")) %>%
  setView(-123.44799, 48.64919, 9) %>%
  addMiniMap(width = 150, height = 150, zoomLevelOffset = -4) %>%
  addControl(title, position = "topright")

# Display map
ECCC_map
# Save map
saveWidget(ECCC_map, "ECCC_map.html")

10.4 Circle Markers Sized to Composite_Index

geo_eccc_all_site_data.csv

geo_eccc_sites_1 <- read.csv("geo_eccc_all_site_data.csv")
names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land_Manager"                 "Main_Restoration_Type"       
##  [5] "Restoration_Intensity"        "Area_ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"
library(dplyr)
library(leaflet)
library(htmlwidgets) # for responsive web map


# Title control
# Malloff & Shackelford. (2024). Feeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. Restoration Futures Lab at the University of Victoria
title <- tags$div(HTML('<p style="font-size:12px;font-weight:bold">ECC Sites Map</p>'))
 
# https://rstudio.github.io/leaflet/articles/markers.html 
# Create a palette that maps factor levels to colors
pal <- colorFactor(c("#d7191c", "#2c7bb6"), domain = c("Saanich Peninsula", "Gulf Islands"))

ECCC_map_1 <- leaflet(geo_eccc_sites_1) %>%
  addProviderTiles("Esri.WorldImagery") %>%
  addCircleMarkers(
             ~ Lng, ~ Lat, 
# https://stackoverflow.com/questions/40137212/variable-marker-size-feature-in-leaflet-r
              radius = ~geo_eccc_sites_1$Composite_Index * 5,    
              # radius = ~geo_eccc_sites_1$Area.ha,
                  # radius = ~sqrt(geo_eccc_sites_1$Area.ha),
 # size smaller is Saanich, else larger if Gulf            
#             radius = ~ifelse(Subregion == "Saanich Peninsula", 4, 5),
    fillColor = ~pal(Subregion),
    color = "black",
    weight = 3, # size of circle border
    stroke = TRUE, fillOpacity = 0.5,
             popup = paste0("<b>Site:</b> ", "<b>", "<b>", geo_eccc_sites_1$Site, "</b>", "</b>", "<br><br>", "<b>Subregion:</b> ", geo_eccc_sites_1$Subregion, "<br>",
                        "<b>Latitude:</b> ", geo_eccc_sites_1$Lat, "<br>", "<b>Longitude:</b> ", geo_eccc_sites_1$Lng,  "<br><br>",
                        "<b>Land Manager:</b> ", geo_eccc_sites_1$Land_Manager, "<br>",
                        "<b>Main Restoration:</b> ", geo_eccc_sites_1$Main_Restoration_Type, "<br>",
                        "<b>Restoration Intensity:</b> ", geo_eccc_sites_1$Restoration_Intensity, "<br>",
                        "<b> Area:</b> ", geo_eccc_sites_1$Area_ha, " ha",
                        "<br><br>",
                        "<b>Proportion of native species:</b> ", geo_eccc_sites_1$Proportion_of_native_species, "<br>",
                        "<b>Cultural species richness:</b> ", geo_eccc_sites_1$Cultural_species_richness, "<br>",
                        "<b>Exotic species:</b> ", geo_eccc_sites_1$Exotic_species, "<br>",
                        "<b>Trampling:</b> ", geo_eccc_sites_1$Trampling, "<br>",
                        "<b>Herbivory:</b> ", geo_eccc_sites_1$Herbivory, "<br>",
                        "<b>Composite Index:</b> ", geo_eccc_sites_1$Composite_Index, "<br>")) %>%
  setView(-123.44799, 48.64919, 10) %>%
  addMiniMap(width = 150, height = 150, zoomLevelOffset = -4) %>%
  addControl(title, position = "topright")

# Display map
ECCC_map_1
# Save map
saveWidget(ECCC_map_1, "ECCC_map_CI.html")

10.5 Circle Markers Sized to Radius

geo_eccc_all_site_data.csv

geo_eccc_sites_1 <- read.csv("geo_eccc_all_site_data.csv")
names(geo_eccc_sites_1)
##  [1] "Subregion"                    "Site"                        
##  [3] "Land_Manager"                 "Main_Restoration_Type"       
##  [5] "Restoration_Intensity"        "Area_ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"
library(dplyr)
library(leaflet)
library(htmlwidgets) # for responsive web map


# Title control
# Malloff & Shackelford. (2024). Feeling the Pulse: Monitoring methods and initial outcomes in oak meadow ecosystems. Restoration Futures Lab at the University of Victoria
title <- tags$div(HTML('<p style="font-size:12px;font-weight:bold">ECC Sites Map</p>'))
 
# https://rstudio.github.io/leaflet/articles/markers.html 
# Create a palette that maps factor levels to colors
pal <- colorFactor(c("#d7191c", "#2c7bb6"), domain = c("Saanich Peninsula", "Gulf Islands"))

ECCC_map_2 <- leaflet(geo_eccc_sites_1) %>%
  addProviderTiles("Esri.WorldImagery") %>%
  addCircleMarkers(
             ~ Lng, ~ Lat, 
# https://stackoverflow.com/questions/40137212/variable-marker-size-feature-in-leaflet-r
#              radius = ~geo_eccc_sites_1$Composite_Index * 5,    
              # radius = ~geo_eccc_sites_1$Area.ha,
                  # radius = ~sqrt(geo_eccc_sites_1$Area.ha),
 # size smaller is Saanich, else larger if Gulf            
             radius = ~ifelse(Subregion == "Saanich Peninsula", 6, 7),
    fillColor = ~pal(Subregion),
    color = "black",
    weight = 3, # size of circle border
    stroke = TRUE, fillOpacity = 0.5,
             popup = paste0("<b>Site:</b> ", "<b>", "<b>", geo_eccc_sites_1$Site, "</b>", "</b>", "<br><br>", "<b>Subregion:</b> ", geo_eccc_sites_1$Subregion, "<br>",
                        "<b>Latitude:</b> ", geo_eccc_sites_1$Lat, "<br>", "<b>Longitude:</b> ", geo_eccc_sites_1$Lng,  "<br><br>",
                        "<b>Land Manager:</b> ", geo_eccc_sites_1$Land_Manager, "<br>",
                        "<b>Main Restoration:</b> ", geo_eccc_sites_1$Main_Restoration_Type, "<br>",
                        "<b>Restoration Intensity:</b> ", geo_eccc_sites_1$Restoration_Intensity, "<br>",
                        "<b> Area:</b> ", geo_eccc_sites_1$Area_ha, " ha",
                        "<br><br>",
                        "<b>Proportion of native species:</b> ", geo_eccc_sites_1$Proportion_of_native_species, "<br>",
                        "<b>Cultural species richness:</b> ", geo_eccc_sites_1$Cultural_species_richness, "<br>",
                        "<b>Exotic species:</b> ", geo_eccc_sites_1$Exotic_species, "<br>",
                        "<b>Trampling:</b> ", geo_eccc_sites_1$Trampling, "<br>",
                        "<b>Herbivory:</b> ", geo_eccc_sites_1$Herbivory, "<br>",
                        "<b>Composite Index:</b> ", geo_eccc_sites_1$Composite_Index, "<br>")) %>%
  setView(-123.44799, 48.64919, 10) %>%
  addMiniMap(width = 150, height = 150, zoomLevelOffset = -4) %>%
  addControl(title, position = "topright")

# Display map
ECCC_map_2
# Save map
saveWidget(ECCC_map_2, "ECCC_map_radius.html")

11 Shiny

11.1 Shiny Gadget

11.1.1 lmGadget all sites

  • code works but can’t knit html file unless adding “echo=TRUE, eval = FALSE”
# colnames(geo_eccc_1)

library(shiny)
library(miniUI)
library(ggplot2)


lmGadget <- function(data, xvar, yvar) {

  ui <- miniPage(
    gadgetTitleBar("Interactive lm"),
    miniContentPanel(
      fillRow(flex = c(NA, 1),
              fillCol(width = "100px",
                      selectInput("degree", "Polynomial degree", c(1, 2, 3, 4))
              ),
              plotOutput("plot1",
                         height = "100%",
                         click = "plot1_click",
                         brush = brushOpts(
                           id = "plot1_brush"
                         )
              )
      )
    ),
    miniButtonBlock(
      actionButton("exclude_toggle", "Toggle points"),
      actionButton("exclude_reset", "Reset")
    )
  )

  server <- function(input, output) {
    # For storing which rows have been excluded
    vals <- reactiveValues(
      keeprows = rep(TRUE, nrow(data))
    )

    output$plot1 <- renderPlot({
      req(input$degree)
      formula <- as.formula(paste0("y ~ poly(x, degree = ", input$degree, ")"))

      # Plot the kept and excluded points as two separate data sets
      keep    <- data[ vals$keeprows, , drop = FALSE]
      exclude <- data[!vals$keeprows, , drop = FALSE]

      ggplot(keep, aes_string(xvar, yvar)) + geom_point() +
        geom_smooth(method = lm, formula = formula, fullrange = TRUE, color = "gray50") +
        geom_point(data = exclude, fill = NA, color = "black", alpha = 0.25) +
        coord_cartesian(xlim = range(data[[xvar]]), ylim = range(data[[yvar]])) +
        theme_bw(base_size = 14)
    })

    # Toggle points that are clicked
    observeEvent(input$plot1_click, {
      res <- nearPoints(data, input$plot1_click, allRows = TRUE)

      vals$keeprows <- xor(vals$keeprows, res$selected_)
    })

    # Toggle points that are brushed, when button is clicked
    observeEvent(input$exclude_toggle, {
      res <- brushedPoints(data, input$plot1_brush, allRows = TRUE)

      vals$keeprows <- xor(vals$keeprows, res$selected_)
    })

    # Reset all points
    observeEvent(input$exclude_reset, {
      vals$keeprows <- rep(TRUE, nrow(data))
    })

    # Handle the Done button being pressed.
    observeEvent(input$done, {
      # Replace x and y in the formula with the values in xvar and yvar
      formula <- as.formula(paste0(yvar, " ~ poly(", xvar, ", degree = ", input$degree, ")"))
      keep_data <- data[vals$keeprows, , drop = FALSE]

      # Return the kept points.
      stopApp(
        list(
          data = keep_data,
          model = lm(formula, keep_data)
        )
      )
    })

  }

    runGadget(ui, server, viewer = dialogViewer("lmGadget")) # separate viewer window
}

lmGadget(geo_eccc_1, "Percentage_ns", "Composite_Index")
lmGadget(iris, "Sepal.Length", "Sepal.Width")

11.2 Inline Shiny app

11.2.1 Reactive choose

## [1] "Subregion"                    "Site"                        
## [3] "Proportion_of_native_species" "Cultural_species_richness"   
## [5] "Exotic_species"               "Trampling"                   
## [7] "Herbivory"                    "Composite_Index"
## 'data.frame':    24 obs. of  8 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Gulf Islands" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Brackman Island" "Crows Nest" ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.77 0.66 0.75 0.53 0.45 0.65 0.62 0.58 ...
##  $ Cultural_species_richness   : num  2.71 1.3 2.8 1.07 3.6 0.8 0.42 2 3.6 2.33 ...
##  $ Exotic_species              : num  0.17 57.19 11.17 31.51 8.8 ...
##  $ Trampling                   : num  5 4.7 5.4 1.64 12.2 ...
##  $ Herbivory                   : num  1.14 36.5 0 26.71 0.1 ...
##  $ Composite_Index             : num  1.8 0.6 2 1 1.6 0.8 0.2 1.4 1 1 ...
## 
## Listening on http://127.0.0.1:5133

11.2.2 Leaflet Reactive Site Details

app-leaflet-reactive-AllSiteDetails-WORKING

## 
## Attaching package: 'bslib'
## The following object is masked from 'package:utils':
## 
##     page
##  [1] "Subregion"                    "Site"                        
##  [3] "Land_Manager"                 "Main_Restoration_Type"       
##  [5] "Restoration_Intensity"        "Area_ha"                     
##  [7] "Lat"                          "Lng"                         
##  [9] "Proportion_of_native_species" "Cultural_species_richness"   
## [11] "Exotic_species"               "Trampling"                   
## [13] "Herbivory"                    "Composite_Index"
## 'data.frame':    24 obs. of  14 variables:
##  $ Subregion                   : chr  "Gulf Islands" "Gulf Islands" "Saanich Peninsula" "Gulf Islands" ...
##  $ Site                        : chr  "Anniversary Island" "AVNR" "Bear Hill Park" "Brackman Island" ...
##  $ Land_Manager                : chr  "GINPR " "Saltspring conservancy" "CRD" "GINPR " ...
##  $ Main_Restoration_Type       : chr  "herbivore reduction" "herbivore reduction" "invasive removal" "invasive removal" ...
##  $ Restoration_Intensity       : chr  "high" "high" "low" "high" ...
##  $ Area_ha                     : num  4.39 20.54 3.8 4.41 10.1 ...
##  $ Lat                         : num  48.8 48.8 48.5 48.7 48.4 ...
##  $ Lng                         : num  -123 -123 -123 -123 -124 ...
##  $ Proportion_of_native_species: num  0.94 0.55 0.62 0.77 0.61 0.66 0.75 0.53 0.32 0.64 ...
##  $ Cultural_species_richness   : num  2.71 1.3 1.86 2.8 2.43 1.07 3.6 0.8 1 4.4 ...
##  $ Exotic_species              : num  0.17 57.19 24.46 11.17 27.19 ...
##  $ Trampling                   : num  5 4.7 7.57 5.4 7.71 1.64 12.2 16.6 10.4 6.2 ...
##  $ Herbivory                   : num  1.14 36.5 9.5 0 4.71 ...
##  $ Composite_Index             : num  1.8 0.6 1 2 1.4 1 1.6 0.8 0.4 1.6 ...
## 
## Listening on http://127.0.0.1:8035

11.2.3 Datatable search plot

app-datatable-search-plot-update-ECCC-TEST https://stackoverflow.com/questions/52880657/in-an-shiny-app-i-want-a-plot-to-update-based-on-the-search-results-in-a-datat

## 
## Attaching package: 'DT'
## The following objects are masked from 'package:shiny':
## 
##     dataTableOutput, renderDataTable
## 
## Listening on http://127.0.0.1:3365

### Plot Select Axis Variables app4-SelectAxisVariables-WORKS.R - this shiny app won’t knit - looses connection ???

## 
## Attaching package: 'shinyscreenshot'
## The following object is masked from 'package:shiny':
## 
##     runExample
## 
## Listening on http://127.0.0.1:5248
## [1] "Exotic_species"
## Warning in file(file, "rt"): cannot open file 'TEST-GOE-Monitor.csv': No such
## file or directory
## Warning: Error in file: cannot open the connection
## [1] "Proportion_of_native_species"
## Warning in file(file, "rt"): cannot open file 'TEST-GOE-Monitor.csv': No such
## file or directory

## Warning in file(file, "rt"): Error in file: cannot open the connection


12 TO DO

  • leaflet map jumps when clicking popup (in RStudio, not in html file)

12.1 DONE

12.1.1 to combine dataframes csv files to include site info

  1. make sure they each have same length number of unique rows
  2. arrange alphabetic order
  3. cbind
  4. remove duplicate columns

13 Session info

# to document specific packages used to run script
sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Mojave 10.14.6
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] shinyscreenshot_0.2.0 DT_0.26               bslib_0.4.0          
##  [4] htmlwidgets_1.5.4     leaflet_2.1.1         plotly_4.10.1        
##  [7] forcats_0.5.2         stringr_1.4.1         dplyr_1.0.10         
## [10] purrr_0.3.5           readr_2.1.3           tidyr_1.2.1          
## [13] tibble_3.1.8          ggplot2_3.4.0         tidyverse_1.3.2      
## [16] shiny_1.7.3          
## 
## loaded via a namespace (and not attached):
##  [1] fs_1.5.2                fontawesome_0.4.0       lubridate_1.8.0        
##  [4] webshot_0.5.4           httr_1.4.4              tools_4.2.1            
##  [7] backports_1.4.1         utf8_1.2.2              R6_2.5.1               
## [10] DBI_1.1.3               lazyeval_0.2.2          colorspace_2.0-3       
## [13] withr_2.5.0             tidyselect_1.2.0        processx_3.7.0         
## [16] compiler_4.2.1          textshaping_0.3.6       cli_3.4.1              
## [19] rvest_1.0.3             xml2_1.3.3              labeling_0.4.2         
## [22] sass_0.4.2              scales_1.2.1            callr_3.7.2            
## [25] systemfonts_1.0.4       digest_0.6.30           rmarkdown_2.17         
## [28] pkgconfig_2.0.3         htmltools_0.5.3         dbplyr_2.2.1           
## [31] fastmap_1.1.0           highr_0.9               rlang_1.0.6            
## [34] readxl_1.4.1            rstudioapi_0.14         jquerylib_0.1.4        
## [37] farver_2.1.1            generics_0.1.3          jsonlite_1.8.2         
## [40] crosstalk_1.2.0         googlesheets4_1.0.1     magrittr_2.0.3         
## [43] Rcpp_1.0.9              munsell_0.5.0           fansi_1.0.3            
## [46] lifecycle_1.0.3         stringi_1.7.8           yaml_2.3.5             
## [49] grid_4.2.1              promises_1.2.0.1        crayon_1.5.2           
## [52] haven_2.5.1             hms_1.1.2               knitr_1.40             
## [55] ps_1.7.1                pillar_1.8.1            uuid_1.1-0             
## [58] markdown_1.1            reprex_2.0.2            glue_1.6.2             
## [61] evaluate_0.17           leaflet.providers_1.9.0 data.table_1.14.2      
## [64] modelr_0.1.9            vctrs_0.5.0             tzdb_0.3.0             
## [67] httpuv_1.6.6            cellranger_1.1.0        gtable_0.3.1           
## [70] assertthat_0.2.1        cachem_1.0.6            xfun_0.37              
## [73] mime_0.12               xtable_1.8-4            broom_1.0.1            
## [76] later_1.3.0             ragg_1.2.3              googledrive_2.0.0      
## [79] viridisLite_0.4.1       gargle_1.2.1            memoise_2.0.1          
## [82] ellipsis_0.3.2